import React from 'react'
import {connect } from 'react-redux'
import { bindActionCreators} from 'redux'

import * as userinfoActions from './actions.js'

import A from './a.jsx'
import B from './b.jsx'
import C from './c.jsx'

class Hello extends React.Component{
    render() {
        return (
            <div>
                <p>hello world</p>
                <hr/>
                <A userinfo = {this.props.userinfo}> </A>
                <hr/>
                <B userinfo = {this.props.userinfo}></B>
                <hr/>
                <C actions = {this.props.actions}></C>
            </div>
        )
    }

    componentDidMount() {
        this.props.actions.login({
            userid: 'opq',
            city: 'hainan'
        })
    }
}

function mapStateToProps(state) {
    return {
        userinfo: state.bb
    }
}

function mapDispatchToProps(dispatch) {
    return {
        actions: bindActionCreators(userinfoActions, dispatch)
    }
}

export default connect(
    mapStateToProps,
    mapDispatchToProps
)(Hello)